package com.haircut.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * Title: ExecutorConfig
 * Description: 自定义线程池
 *
 * @version 1.0.0
 * @date 2021/6/21 17:41
 */
@Configuration
public class ExecutorConfig {

    /**
     * 售后消息发送的线程池
     * @return
     */
    @Bean("salaryExecutor")
    public AsyncTaskExecutor autoBatchExecutor() {
        ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
        taskExecutor.setMaxPoolSize(10);
        taskExecutor.setCorePoolSize(3);
        taskExecutor.setThreadNamePrefix("async-auto-salary-executor");
        taskExecutor.initialize();
        return taskExecutor;
    }
}
